package com.yetm.springbootdemo.utils;

import org.springframework.stereotype.Component;

@Component
public class ResultGenerator {

    private static final int HTTP_CODE_SUCCESS = 200;
    private static final int HTTP_CODE_ERROR = 500;

    public Result successResult () {
        Result result = new Result();
        result.setCode(HTTP_CODE_SUCCESS);
        return result;
    }

    public Result successResult(int code) {
        Result result = new Result();
        result.setCode(code);
        return result;
    }

    public Result successResult(Object data) {
        Result result = new Result();
        result.setData(data);
        return result;
    }

    public Result failResult() {
        Result result = new Result();
        result.setCode(HTTP_CODE_ERROR);
        return result;
    }

}
